<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Field_Radio extends Field_Abstract {

  protected $type = 'radio';

  public function getHtml() {
    return sprintf('<input name="%s" type="%s" value="%s" %s />', $this->getName(), $this->_type, $this->getValue(), $this->getExtras());
  }

  protected function _optionToHtml() {
    $options = (array) $this->_params['options'];
    $value = $this->getValue();
    $opts = array();
    foreach ($options as $v => $t) {
      $opts[] = sprintf('<input name="%s" type="radio" value="%s" %s/>%s', $v, $value == $v ? 'selected="selected"' : '', $t);
    }
    return implode(" ", $opts);
  }

}
